﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Web;

namespace EmptoolWebApp.Entities
{
    //public enum CompanyAssociationType : int
    //{
    //    UNRELATED = 0,
    //    EMPLOYEE = 1
    //}

    public class CompanyAssociationType
    {
        public const int UNRELATED = 0;
        public const int EMPLOYEE = 1;

        public static string GetName(int t)
        {
            string typeName = string.Empty;

            switch (t)
            {
                case Entities.CompanyAssociationType.UNRELATED:
                    typeName = "UNRELATED";
                    break;
                case Entities.CompanyAssociationType.EMPLOYEE:
                    typeName = "EMPLOYEE";
                    break;
            }

            return typeName;
        }
    }

    [Serializable]
    [DataContract]
    public class CompanyAssociateEntity : BaseTableEntity
    {
        public const string TABLE_NAME = "CompanyAssociate";

        #region constructor(s)
        public CompanyAssociateEntity() : base()
        {

        }

        public CompanyAssociateEntity(string companyName, string associateName, int associationType) : base()
        {
            if (string.IsNullOrWhiteSpace(companyName))
            {
                throw new ArgumentNullException("companyName");
            }

            if (string.IsNullOrWhiteSpace(associateName))
            {
                throw new ArgumentNullException("associateName");
            }

            this.PartitionKey = Helpers.CryptographyHelper.UserHash(companyName);
            this.RowKey = Helpers.CryptographyHelper.UserHash(associateName);
            this.CompanyName = companyName;
            this.AssociateName = associateName;
            this.AssociationType = associationType;
        }
        #endregion constructor(s)


        [DataMember]
        public string CompanyName { get; set; }

        [DataMember]
        public string AssociateName { get; set; }

        [DataMember]
        public int AssociationType { get; set; }

    }
}